package pk.nak.requests;

import java.util.ArrayList;
import java.util.Date;

import pk.nak.enums.TossDownURLs;
import pk.nak.responses.CheckInResponse;
import pk.nak.utils.FormattingUtils;

import com.loopj.android.http.RequestParams;

public class CheckedInRequest extends PostRequest {

	public CheckedInRequest(String userid, String eatoutid, String attributes) {
		
		super(TossDownURLs.ADD, null);
		
		RequestParams parms = new RequestParams();
		Date dtNow = new Date();
		String strNow = dtNow.getYear() + "-" + 
						dtNow.getMonth() + "-" + 
						dtNow.getDate() + " " + 
						dtNow.getHours() + ":" + 
						dtNow.getMinutes() + ":" + 
						dtNow.getSeconds();
		ArrayList<String> fields = new ArrayList<String>();
		ArrayList<String> values = new ArrayList<String>();
		
		fields.add("userid");
		values.add(FormattingUtils.IntoDBFormat(userid));
		
		fields.add("eatoutid");
		values.add(FormattingUtils.IntoDBFormat(eatoutid));
		
		fields.add("attributes");
		values.add(FormattingUtils.IntoDBFormat(attributes));
		
		fields.add("timestamp");
		values.add(FormattingUtils.IntoDBFormat(strNow));
				
		
		String ff = FormattingUtils.getJoin(fields, ",");
		String fv = FormattingUtils.getJoin(values, ",");
		
		parms.put("table", "trends_checkin");
		parms.put("fields", ff);
		parms.put("values", fv);

		this.setData(parms);
	}

	public void doRequest(CheckInResponse responseHandler) {
		super.doRequest(responseHandler);
	}

}
